home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Paypal_En / Configuration / Commands / Insert PayPal Add to Cart.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  10.4 KB  |  355 lines

  1. /*-----------------------------------------------------------------------------
  2. -    File Name:
  3. -        Insert PayPal Add to Cart.js
  4. -
  5. -    Description:
  6. -        Functions for Add to Cart wizard.
  7. -
  8. -    This file contains proprietary and confidential information from WebAssist.com
  9. -    corporation.  Any unauthorized reuse, reproduction, or modification without
  10. -    the prior written consent of WebAssist.com is strictly prohibited.
  11. -
  12. -    Copyright 2001 WebAssist.com Corporation.  All rights reserved.
  13. ------------------------------------------------------------------------------*/
  14. var CURRENTPAGE=0;
  15.  
  16. function commandButtons()     {
  17.   return new Array();
  18. }
  19.  
  20. /* Initialize the UI.  First thing that's called on the body load event. */
  21. function initializeUI()     {
  22.   if (navigator.platform.toLowerCase().indexOf("mac") >= 0)     {
  23.  
  24.     document.cancel.style = "position:absolute; width:70px; height:20px; z-index:90; left: 245px; top: 397px; visibility: visible";
  25.     document.cancel.document.btnCancel.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  26.         
  27.     document.help.style = "position:absolute; width:70px; height:20px; z-index:90; left: 175px; top: 397px; visibility: visible";
  28.     document.help.document.btnHelp.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  29.         
  30.     document.next.style = "position:absolute; width:70px; height:20px; z-index:90; left: 385px; top: 397px; visibility: visible";
  31.     document.next.document.btnNext.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  32.         
  33.     document.back.style = "position:absolute; width:70px; height:20px; z-index:90; left: 315px; top: 397px; visibility: visible";
  34.     document.back.document.btnBack.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  35.         
  36.     document.finish.style = "position:absolute; width:70px; height:20px; z-index:90; left: 385px; top: 397px; visibility: visible";
  37.     document.finish.document.btnFinish.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  38.   
  39.     document.walogo.top = 402;
  40.     document.pplogo.top = 403;
  41.   }
  42.   document.back.visibility = "visible";
  43.   document.next.visibility = "visible";
  44.   document.help.visibility = "visible";
  45.   document.cancel.visibility = "visible";
  46.   var theDOM = dreamweaver.getDocumentDOM();
  47.   var theParent = theDOM.getSelectedNode();
  48.   var inForm = false;
  49.   while (theParent.parentNode)  {
  50.     theParent = theParent.parentNode;
  51.     if (theParent.tagName=="FORM")  {
  52.         inForm = theParent;
  53.         break;
  54.     }
  55.     }
  56.   if (inForm)  {
  57.     if (inForm.innerHTML.search(/<input type="[^"]*"[^>]*\sname="cmd"[^>]*>/i)>=0)  
  58.     {
  59.       alert(MSG_AlreadyPayPalInForm);
  60.       window.close();
  61.     }
  62.   }
  63.   MM.setBusyCursor();
  64.   // Show the first screen in the wizard
  65.   showPageNum(0);
  66.   getLastUID();  
  67.   enableDisableOtherImage('AC');
  68.   MM.clearBusyCursor();
  69. }
  70.  
  71. /******************************** support functions ******************/
  72. function buildSummaryText()     {
  73.   var retVal = "";
  74.   var myID       = findObject("ppUID").value;
  75.   var myImage    = findObject("acimage");
  76.   var myImageURL = "";
  77.   var myItemName = findObject("itemName").value;
  78.   var myItemID = findObject("itemID").value;
  79.   var myAmount = findObject("itemPrice").value;
  80.   var myCurrency = findObject("itemCurrency").options[findObject("itemCurrency").selectedIndex].value;  
  81.   var myQuantityYes = findObject("quantityYes").checked;
  82.   var myShippingNo = findObject("shippingNo")[1].checked;
  83.   var myIncludeNote = true;
  84.   if (findObject("includeNote")[1].checked)
  85.   {
  86.     myIncludeNote = false;
  87.   }
  88.   var myLogoURL = findObject("ppLogo").value;
  89.   var mySuccessURL = findObject("successURL").value;
  90.   var myCancelURL = findObject("cancelURL").value;
  91.     
  92.   retVal += "PayPal Account: " + myID;
  93.   retVal += "\n";
  94.   retVal += "Button Image URL: ";
  95.   for (var n=0; n<myImage.length; n++)
  96.   {
  97.     if (myImage[n].checked)
  98.     {
  99.       if (myImage[n].value == "other")
  100.       {
  101.         retVal += findObject("otheracimage").value;      
  102.       }
  103.       else
  104.       {
  105.         retVal += "http://images.paypal.com/images/" + myImage[n].value;      
  106.       }
  107.     }
  108.   }
  109.   retVal += "\n";
  110.  
  111.   if (myItemName != "")
  112.   {
  113.     retVal += "Item Name: " + myItemName + "\n";
  114.   }
  115.   
  116.   if (myItemID != "")
  117.   {
  118.     retVal += "Item Number: " + myItemID + "\n";  
  119.   }
  120.   
  121.   if (myAmount != "")
  122.   {
  123.     retVal += "Item Amount: " + myAmount + "\n";    
  124.   }
  125.  
  126.   retVal += "Currency: " + getCurrencyType(myCurrency) + "\n";    
  127.  
  128.   retVal += "Allow Customer to Edit Quantity: ";    
  129.   if (myQuantityYes)
  130.     retVal += "Yes";
  131.   else
  132.     retVal += "No";  
  133.   retVal +="\n";      
  134.  
  135.   retVal += "Require Shipping Information: ";    
  136.   if (myShippingNo)
  137.     retVal += "No";
  138.   else
  139.     retVal += "Yes";
  140.   retVal +="\n";
  141.          
  142.   retVal += "Allow Customer Note: ";    
  143.   if (!myIncludeNote)
  144.     retVal += "No";
  145.   else
  146.     retVal += "Yes";  
  147.   retVal +="\n";
  148.   
  149.   if (isValidURL(myLogoURL))
  150.   {
  151.     retVal += "Custom Logo URL: " + myLogoURL + "\n";
  152.   }
  153.   
  154.   if (isValidURL(mySuccessURL))
  155.   {
  156.     retVal += "Successful Payment URL: " + mySuccessURL + "\n";
  157.   }
  158.   
  159.   if (isValidURL(myCancelURL))
  160.   {
  161.     retVal += "Cancelled Payment URL: " + myCancelURL + "\n";
  162.   }
  163.         
  164.   return retVal;
  165. }
  166.  
  167. function openBrowseImageWindow()      {
  168.   var browseURL = "";
  169.   var LABEL_Select = "Select Add to Cart Image...";  // label for file window
  170.   browseURL = dreamweaver.browseForFileURL("select",LABEL_Select, false, true); // opens file window and returns file string as URL
  171.   if (browseURL)
  172.   {
  173.     //browseURL = WA_absoluteToRelativeURL(browseURL, docpath, false);          
  174.     findObject("otheracimage").value = browseURL;  //set the DataSource    
  175.   }
  176.   findObject("otheracimage").focus();
  177. }
  178.  
  179.  
  180. /****************************** page functions ****************************/
  181. function Pg0_load()
  182. {
  183.   document.UserIDWP.visibility = "visible";
  184.   findObject("btnBack").setAttribute("disabled", "disabled"); // disable the back button
  185.   findObject("next").visibility = "visible";                  // enable next button
  186.   findObject("finish").visibility = "hidden";                 // hide finish button
  187.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  188.   setTimeout('findObject("ppUID").focus()',500);
  189.   return true;
  190. }
  191.  
  192. function Pg0_unLoad()
  193. {
  194.   document.UserIDWP.visibility = "hidden";
  195.   return true;
  196. }
  197.  
  198. function Pg1_canLoad()      {
  199.   var ppError = validatePPUID();
  200.   if (ppError != "")
  201.   {
  202.     alert ("Account " + ppError);
  203.     return false;
  204.   }
  205.   return true;
  206. }
  207.  
  208. function Pg1_load()
  209. {
  210.   document.ButtonImageWP.visibility = "visible";
  211.   findObject("btnBack").setAttribute("disabled", "enabled");  // disable the back button
  212.   findObject("next").visibility = "visible";                  // enable next button
  213.   findObject("finish").visibility = "hidden";                 // hide finish button
  214.   //setTimeout('findObject("acimage").focus()',500);
  215.   return true;
  216. }
  217.  
  218. function Pg1_unLoad()
  219. {
  220.   document.ButtonImageWP.visibility = "hidden";
  221.   return true;
  222. }
  223.  
  224. function Pg2_canLoad() 
  225. {
  226.   return true;
  227. }
  228.  
  229. function Pg2_load()
  230. {
  231.   document.itemWP.visibility = "visible";
  232.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  233.   findObject("next").visibility = "visible";                  // enable next button
  234.   findObject("finish").visibility = "hidden";                 // hide finish button
  235.  
  236.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  237.   setTimeout('findObject("itemName").focus()',500);
  238.   return true;
  239. }
  240.  
  241. function Pg2_unLoad()
  242. {
  243.   document.itemWP.visibility = "hidden";
  244.   return true;
  245. }
  246.  
  247. function Pg3_canLoad() 
  248. {
  249.   var itemNameErr = validateItemName();
  250.   var itemPriceErr = validateItemPrice();
  251.   var errMsg = "";
  252.  
  253.   if (itemNameErr != "")
  254.   {
  255.     itemNameErr = "Item Name " + itemNameErr; 
  256.   }
  257.   
  258.   if (itemPriceErr != "")
  259.   {
  260.     itemPriceErr = "Item Price " + itemPriceErr; 
  261.   }
  262.   
  263.   if ((itemNameErr != "") || (itemPriceErr != ""))
  264.   {
  265.     alert (itemNameErr + itemPriceErr);   
  266.     return false;
  267.   }
  268.  
  269.   return true;
  270. }
  271.  
  272. function Pg3_load()
  273. {
  274.   document.logoWP.visibility = "visible";
  275.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  276.   findObject("next").visibility = "visible";                  // enable next button
  277.   findObject("finish").visibility = "hidden";                 // hide finish button
  278.  
  279.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  280.   setTimeout('findObject("ppLogo").focus()',500);
  281.   return true;
  282. }
  283.  
  284. function Pg3_unLoad()
  285. {
  286.   document.logoWP.visibility = "hidden";
  287.   return true;
  288. }
  289.  
  290. function Pg4_canLoad() 
  291. {
  292.   return true;
  293. }
  294.  
  295. function Pg4_load()
  296. {
  297.   document.customWP.visibility = "visible";
  298.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  299.   findObject("next").visibility = "visible";                  // enable next button
  300.   findObject("finish").visibility = "hidden";                 // hide finish button
  301.  
  302.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  303.   setTimeout('findObject("successURL").focus()',500);
  304.   return true;
  305. }
  306.  
  307. function Pg4_unLoad()
  308. {
  309.   document.customWP.visibility = "hidden";
  310.   return true;
  311. }
  312.  
  313. function Pg5_canLoad() 
  314. {
  315.   return true;
  316. }
  317.  
  318. function Pg5_load()
  319. {
  320.   document.SummaryWP.visibility = "visible";
  321.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  322.   findObject("next").visibility = "hidden";                  // enable next button
  323.   findObject("finish").visibility = "visible";                 // hide finish button
  324.  
  325.   findObject("summaryText").value = buildSummaryText();
  326.   return true;
  327. }
  328.  
  329. function Pg5_unLoad()
  330. {
  331.   document.SummaryWP.visibility = "hidden";
  332.   return true;
  333. }
  334.  
  335. function showNextPage()   {
  336.   var nextPage = CURRENTPAGE + 1;
  337.   if (eval("Pg"+nextPage+"_canLoad()"))
  338.   {
  339.     eval("Pg"+CURRENTPAGE+"_unLoad()");
  340.     CURRENTPAGE++;
  341.     eval("Pg"+CURRENTPAGE+"_load()");  
  342.   }
  343. }
  344.  
  345. function showPreviousPage()   {
  346.   eval("Pg"+CURRENTPAGE+"_unLoad()");
  347.   CURRENTPAGE--;
  348.   eval("Pg"+CURRENTPAGE+"_load()");
  349. }
  350.  
  351. function showPageNum(pageNum)  {
  352.   eval("Pg"+CURRENTPAGE+"_unLoad()");
  353.   CURRENTPAGE = pageNum;
  354.   eval("Pg"+CURRENTPAGE+"_load()");
  355. }